package com.atguigu.boot.activemq.consumer;

import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import javax.jms.JMSException;
import javax.jms.TextMessage;

/**
 * topic消费者
 */
@Component
public class Topic_Consumer {
    @JmsListener(destination = "${mytopic}") // 采用监听器的方式
    public void receive(TextMessage textMessage) throws JMSException {
        try {
            System.out.println("消费者收到topic消息：" + textMessage.getText());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
